<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.icss.th.question.pojo.Question"%>
<%@ page import="com.icss.th.question.pojo.Item"%>
<%@ page import="com.icss.th.common.util.StringUtil"%>
<%
	Question q = (Question)request.getAttribute("question");
	String context = request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
<title>题海</title>
<meta charset="UTF-8">
<link href="includes/css/style.css" rel="stylesheet" type="text/css">
<link href="includes/css/jquery-ui.min.css" rel="stylesheet" type="text/css">
</head>
<body>
<!--弹出窗口开始-->
<div id="correct" style="display: none;">
    <div style="margin:20px;" >
        <form id="correctForm" name="correctForm" method="post" action="<%=context%>/correct">
        <div>
            <ul>
                <li style="font-size:14px; font-weight:bold; color:#069; line-height:40px;">为了方便我们排查错误，请您详细描述本题错误，例如：</li>
                <li>
                    <table style="width:400px">
                      <tr>
                        <td>
                        <label><input name="optionType" type="checkbox" id="optionType_1" value="1">错别字</label>
                        </td>
                        <td>
                        <label><input name="optionType" type="checkbox" id="optionType_2" value="2">答案错误</label>
                        </td>
                        <td>
                        <label><input name="optionType" type="checkbox" id="optionType_3" value="3">图片模糊</label>
                        </td>
                        <td>
                        <label><input name="optionType" type="checkbox" id="optionType_4" value="4">排版错误</label>
                        </td>
                        <td>
                        <label><input name="optionType" type="checkbox" id="optionType_5" value="5">答案有异议</label>
                        </td>
                      </tr>
                    </table>
                </li>
                <li>
                	<label><textarea id="correctContent" name="correctContent" style="width:95%;text-align: left;" rows="10"></textarea></label>
                </li>
                <li>还可以输入150个字</li>
                <li style="text-align:right; padding-right:30px;"><a href="#" class="s_botton" onclick="_correctSubmit();"><strong>确定提交</strong></a></li>
            </ul>
        </div>
        </form>
    </div>
</div>

<div id="explain" style="display: none;">
    <div style="margin:20px;" >
        <form id="explainForm" name="explainForm" method="post" action="">
	        <div>
	            <ul>
	                <li>
	                	<label><textarea id="explainContent" name="explainContent" style="width:99%; text-align: left;" rows="15"></textarea></label>
	                </li>
	                <li style="text-align:right; padding-top:15px; padding-right:30px;">
	                	<a href="#" class="s_botton" onclick="_explainSubmit()" ><strong>确定提交</strong></a>
	                </li>
	            </ul>
	        </div>
        </form>
    </div>
</div>
<!--弹出窗口结束-->

<div id=wrapper>
    <div id=content1>
        <div id=u style="background-color:#fc9b00;-webkit-gradient(linear,0% 0%, 0% 100%, from(#fc9b00), to(#f18000)); border-bottom:1px solid #333;-moz-box-shadow:0px 2px 5px #666; -webkit-box-shadow:0px 2px 5px #666; box-shadow:0px 2px 5px #666;">
            <div id=user>
                <span style="float:left; padding-left:20px; padding-top:2px;"><img src="includes/images/title.png" width="71" height="34"></span>
                <span style="float:left; padding-left:40px; padding-top:8px;">
                	<a href="<%=context%>/"><img src="includes/images/home.png" width="25" height="23"></a>
                </span>
               	<input type="hidden" name="subjectId" id="subjectId" value="<%=q.getTypeId()%>">
               	<div class="input-bg">
               		<input type="text" name="keyword" maxlength="38" id="keyword" x-webkit-speech class=top_input />
              			<a href="#" onclick="_submit()" ><img style="margin-top:3px;" src="includes/images/seek.png" width="23" height="20"></a>
               	</div>
                <div id=userMenu>
                <a href="#">登录</a>&nbsp;<font color="#f68d00" size="2">|</font>&nbsp;
                <a href="#">快速入口</a>&nbsp;<font color="#f68d00">|</font>&nbsp;
                <a href="#">合作接口</a>
                </div>
            </div>
        </div>
    </div>
	<div id=m_list>

        <div style="padding-left:10px; margin-left:120px; margin-bottom:3px; height:30px; float:left;">
            <ul>
                <li style="font-size:14px; color:#666; font-weight:bold; line-height:25px; float:left; margin-right:0px;">本题来源：</li>
                <li style="font-size:14px; color: #069; font-weight:bold; line-height:25px; float:left; margin-right:50px;font-family:arial"><%=q.getPaperName()%></li>
                <li style=" float:left; font-size:12px; line-height:25px; padding-top:0px; color:#666; margin-right:10px;"><a href="#" onclick="AddFavorite()" class="s_botton1">收藏</a></li>
                <li style=" float:left; font-size:12px; line-height:25px; padding-top:0px; color:#666; margin-right:10px;"><a href="<%=context%>/paper?id=<%=q.getPaperId()%>" class="s_botton1">查看试卷其它试题</a></li>
                <li style=" float:left; font-size:12px; line-height:25px; padding-top:0px; color:#666; margin-right:10px;"><a onclick="openExplain();"></a></li>
            </ul>
        </div>
	</div>

    <div style="padding-left:10px; margin-left:120px; width:500px; margin-top:10px; height:30px; position:absolute;">
		<ul style="margin-bottom:10px;">
            <li style="font-size:14px; color: #C60; line-height:22px; margin-right:0px;font-family:arial">[<%=q.getTypeName()%>]</li>
        </ul>
        <ul style="margin-bottom:20px;">
            <li style="font-size:14px; color:#444; line-height:26px; margin-right:0px;font-family:arial"><%=q.getTitle()%></li>
        </ul>
        <ul style="margin-bottom:20px;" id="select1">
        <%
        	for (Item item : q.getItems())
        	{
        %>
        	<li style="font-size:14px; color: #06C; line-height:28px; margin-right:0px;font-family:arial">
        		<%=item.getSign()%>、<%=item.getContent()%>
        		<br/>
        	</li>
        <%
        	}
        %>
        </ul>
        
        <!-- ==========分享========== -->
        <div class="bshare-custom icon-medium" style="margin-bottom:20px;" >
        	<a title="分享到" href="http://www.bShare.cn/" id="bshare-shareto" class="bshare-more">分享到</a>
        	<a title="分享到QQ空间" class="bshare-qzone"></a>
        	<a title="分享到新浪微博" class="bshare-sinaminiblog"></a>
        	<a title="分享到人人网" class="bshare-renren"></a>
        	<a title="分享到腾讯微博" class="bshare-qqmb"></a>
        	<a title="分享到网易微博" class="bshare-neteasemb"></a>
        	<a title="更多平台" class="bshare-more bshare-more-icon more-style-addthis"></a>
        	<span class="BSHARE_COUNT bshare-share-count">0</span>
        </div>
        <!-- ==========分享========== -->
        
        <ul style="margin-bottom:20px;">
            <li style="font-size:14px; color:#666; line-height:17px; margin-right:0px;"><strong>参考答案：</strong></li>
            <li style="font-size:16px; color:#444; line-height:26px; margin-right:0px;font-family:arial"><%=q.getAnswer()%></li>
        </ul>
         <ul style="margin-bottom:20px;">
            <li style="font-size:14px; color:#666; line-height:17px; margin-right:0px;"><strong>题目详解：</strong></li>
            <li style="font-size:14px; color:#444; line-height:26px; margin-right:0px;font-family:arial"><%=q.getExplain()%></li>
        </ul>
        <div>
            <ul style="margin-bottom:20px;">
                <li style="font-size:14px; color:#666; line-height:17px; margin-right:0px; text-align:right;">
                	<a href="javascript: openCorrect();" class="s_botton1" id="bt">纠错</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                	<a href="javascript: openExplain();" class="s_botton1" >我来解析</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                	<a href="javascript:_findSource()" class="s_botton1">查看来源网站或个人提交者</a>
                </li>
            </ul>
        </div>

        <ul style="height:30px; margin-bottom:50px; text-align:right;">
            <li><a id="previous" href="<%=context%>/question?id=<%=q.getId()%>&paperId=<%=q.getPaperId()%>&sort=<%=q.getPaperSort()%>&next=-1" class="s_botton"><strong>上一题</strong></a>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a id="next" href="<%=context%>/question?id=<%=q.getId()%>&paperId=<%=q.getPaperId()%>&sort=<%=q.getPaperSort()%>&next=1" class="s_botton"><strong>下一题</strong></a></li>
        </ul>
        
        <ul style="height:30px; margin-bottom:1px; text-align:left;">
            <li><a href="#" onclick="AddFavorite()">加入收藏夹</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#">关于我们</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#">加入我们</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#">支持与捐赠</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#">开放接口</a></li>
            <li>©2013&nbsp;Tihai.org&nbsp;北京题海科技有限公司&nbsp;<a href="#" >使用必读</a>&nbsp;<a href="#" target="_blank">冀ICP备08007478号</a></li>
        </ul>
    </div>

   

</div>
<script src="includes/js/jquery-1.10.0.min.js" type="text/javascript"></script>
<script src="includes/js/jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8" src="http://static.bshare.cn/b/buttonLite.js#style=-1&amp;uuid=46e833e4-e443-4572-a601-0b0de0b4d72f&amp;pophcol=2&amp;lang=zh"></script>
<script type="text/javascript" charset="utf-8" src="http://static.bshare.cn/b/bshareC0.js"></script>
<script type="text/javascript">
	bShare.init(); 
	
	$("#keyword").keypress(function(event){
		if ( event.which == 13 ) {
			_submit();
		}
	});
	
	document.onkeydown = function(event){
	    if (window.event && window.event.keyCode == 33){
	    	window.location.href = "<%=context%>/question?id=<%=q.getId()%>&paperId=<%=q.getPaperId()%>&sort=<%=q.getPaperSort()%>&next=-1";
	    }else if (window.event && window.event.keyCode == 34){
	    	window.location.href = "<%=context%>/question?id=<%=q.getId()%>&paperId=<%=q.getPaperId()%>&sort=<%=q.getPaperSort()%>&next=1";
	    }
	}
	
	
	//弹出纠错窗口
	function openCorrect(){
		$('#correctContent').val('');
		$("[name = optionType]:checkbox").attr("checked", false);
		$("#correct").dialog({
			modal: true,
			width: 700,
			resizable: false,
			draggable: false,
			title: '错题举报',
			close: function(event, ui) {
				$("#correct").hide();
			}
		});
	}
	
	//弹出解析窗口
	function openExplain(){
		$('#explainContent').val('');
		$("#explain").dialog({
			modal: true,
			width: 700,
			resizable: false,
			draggable: false,
			title: '我来解析',
			close: function(event, ui) {
				$("#explain").hide();
			}
		});
	}
	
	
	function _submit(){
		if ($.trim($("#keyword").val())){
			var path = '<%=context%>/search?';
			path += 'subjectId=' + $("#subjectId").val();
			path += '&keyword=' + encodeURI(encodeURI($("#keyword").val()));
			location.href = path;
		}else{
			location.reload();
		}
	}
	
	function _explainSubmit(){
		$.ajax({
			type:"POST",
			cache:false,
			url:"<%=context%>/explain",
			data:{
				content: $('#explainContent').val(),
				examId: '<%=q.getId() %>'
			},
	    	success:function(msg){
	    		if (msg) $("#content").append('<div>' + msg + '</div>');
	    		$("#explain").dialog( "close" );
			}
		}); 
	}
	
	function _correctSubmit(){
		var chk_value =[];    
		$('input[name="optionType"]:checked').each(function(){    
			chk_value.push($(this).val());    
		});
		$.ajax({
			type:"POST",
			cache:false,
			url:"<%=context%>/correct",
			data:{
				content: $('#correctContent').val(),
				optionType: chk_value.toString(),
				examId: '<%=q.getId() %>'
			},
	    	success:function(msg){
	    		if (msg) $("#content").append('<div>' + msg + '</div>');
	    		$("#correct").dialog( "close" );
			}
		}); 
	}
	
	function _findSource(){
		<%
			String ctx = StringUtil.delHTMLTag(q.getTitle());
		%>
		window.open("http://www.baidu.com/s?wd=" + encodeURI('<%=ctx.length() >= 38? ctx.substring(0, 38) : ctx%>'));
	}
	
	function AddFavorite(){
		var sURL = window.location;
		var sTitle = document.title;
	    try{
	        window.external.addFavorite(sURL, sTitle);
	    }catch (e){
	        try{
	            window.sidebar.addPanel(sTitle, sURL, "");
	        }catch (e){
	            alert("加入收藏失败，请使用Ctrl+D进行添加");
	        }
	    }
	}
</script>
</body>
</html>
